package updater.currency.xml;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.thoughtworks.xstream.*;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class Writer {

	public static void main(String[] args) {
		Employee e = new Employee();
		
		//Set the properties using the setter methods
		//Note: This can also be done with a constructor.
		//Since we want to show that XStream can serialize
		//even without a constructor, this approach is used.
		e.setName("Jack");
		e.setDesignation("Manager");
		e.setDepartment("Finance");
		

		//Serialize the object
	//	XStream xd = new XStream();
		XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library
		
		//Write to a file in the file system
		String filePath = "Data/employeedata.xml";
		String currentPath = new File(filePath).getAbsolutePath();
		
		System.out.println(currentPath);
		try {
		
			FileOutputStream fs = new FileOutputStream(currentPath);
			xstream.toXML(e, fs);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
	}
}